#include "opencv2/highgui.hpp"
#include <iostream>

int main(int argc, char *argv[]){
    cv::VideoCapture input_stream(0);
    if(!input_stream.isOpened()){
        std::cerr<<"Could not open camera\n";
        return EXIT_FAILURE;
    }
    const std::string window_title = "Lab 0:Intro to OpenCV";
    cv::namedWindow(window_title, cv::WINDOW_NORMAL);
    cv::Mat frame;

    while(true){
        input_stream>>frame;
        if(frame.empty()){
            std::cerr<<"Failed to capture frame\n";
            break;
        }
        cv::imshow(window_title,frame);
        if(cv::waitKey(15)>=0){
            break;
        }
    }
    input_stream.release();
    cv::destroyAllWindows();
    return 0;
}